#!/bin/bash
# 用来添加mysql以及授权账号
mysql -uroot -p123456 <<EOF
create user 'user'@'%' identified by 'user123';
grant all on *.* to 'user'@'%';
ALTER USER 'user'@'%' IDENTIFIED WITH mysql_native_password BY 'user123';
EOF
exit;
#本地手动运行创建命令 docker exec -it mysql /bin/bash /docker-entrypoint-initdb.d/mysql.sh
#启动会自动执行,不需要手动创建